package com.chb.controller;

import com.chb.model.vo.Result;
import com.chb.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 陈海彬
 * @date: Created in 2023/9/25 16:14
 * @description: 用户表控制层
 * @modified By:
 * @version: 1.0
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    /**
     * @create by: 陈海彬
     * @description: 获取左侧菜单栏
     * @create time: 2023/9/25 16:17
     */
    @GetMapping("/leftMenu")
    public Result getLeftMenu() {
        Result leftMenu = menuService.getLeftMenu();
        return leftMenu;
    }

    /**
     *修改权限中获取菜单信息
     * @param roleid
     * @return
     */
    @PostMapping("/list")
    public Result list(Integer roleid){
        Result result = menuService.selectMidByRoleid(roleid);
        return result;
    }

    /**
     * 将角色重新赋有新的菜单id
     * @param roleId(角色id)
     * @param ids(角色具有菜单id)
     * @return
     */
    @PostMapping("/modify")
    public Result modifylist(Integer roleId,Integer[] ids){
        Result result = menuService.modifyMidByRoleid(roleId, ids);
        return result;
    }
}